#include <cstdio>
constexpr int MaxN = 1e3 + 5;
long long l, r;
long long answer;
bool c[MaxN][MaxN];
void solve()
{
    scanf("%lld%lld", &l, &r);
    answer = 0;
    for (long long n = l; n <= r; n++)
    {
        for (long long m = l; m <= n; m++)
        {
            answer += c[n][m] ? 1 : 0;
        }
    }
    printf("%lld\n", answer);
}
int main()
{
    freopen("comb.in", "r", stdin);
    freopen("comb.out", "w", stdout);
    for (int i = 1; i <= 1000; i++)
    {
        c[i][1] = i & 1;
        for (int j = 2; j <= i; j++)
        {
            c[i][j] = c[i][j - 1] ^ c[i - 1][j - 1];
        }
    }
    int t;
    scanf("%d", &t);
    for (int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}